package com.drg.center.controller;

import com.drg.center.entity.param.SysDictAddDTO;
import com.drg.center.entity.param.SysDictEditDTO;
import com.drg.center.entity.param.SysDictListDTO;
import com.drg.center.entity.result.SysDictVO;
import com.guaike.core.entity.result.PageEntity;
import com.guaike.core.entity.result.Result;
import com.drg.center.service.DictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @Author: zhangxilin
 * @Date: 2023/10/27
 */
@RestController
@RequestMapping("/dict")
@Api(tags = "系统-字典类型接口组")
public class SysDictController {

    @Autowired
    private DictService dictService;

    @GetMapping("/findPage")
    @ApiOperation(value = "列表")
    public Result<PageEntity<SysDictVO>> list(@Valid SysDictListDTO param){
        return dictService.list(param);
    }

    @PostMapping("/add")
    @ApiOperation(value = "添加")
    public Result<Boolean> add(@Valid @RequestBody SysDictAddDTO param){
        return dictService.add(param);
    }

    @PostMapping("/edit")
    @ApiOperation(value = "编辑")
    public Result<Boolean> edit(@Valid @RequestBody SysDictEditDTO param){
        return dictService.edit(param);
    }


    @DeleteMapping("/delete")
    @ApiOperation(value = "删除")
    public Result<Boolean> delete(@ApiParam("ID") @RequestParam("id") Long id){
        return dictService.delete(id);
    }
}
